<?php

/**
 * Picon Framework
 * http://code.google.com/p/picon-framework/
 *
 * Copyright (C) 2011-2012 Martin Cassidy <martin.cassidy@webquub.com>

 * Picon Framework is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * Picon Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Picon Framework.  If not, see <http://www.gnu.org/licenses/>.
 * */

namespace picon;

/**
 * A database driver implements internally the PHP functions and methods
 * required when working with a particular DBMS or PHP extension
 * 
 * All errors within a driver should be thrown as exceptions for handling
 * by the class using the driver
 * 
 * @author Martin Cassidy
 * @package database/driver
 */
interface DatabaseDriver
{
    /**
     * Establish a connection with given settings
     * @return resource the connection
     */
    function connect($host, $username, $password, $database, $port = null);
    
    /**
     * Disconnect the given connection
     */
    function dissconnect($connection);
    
    /**
     * Run a query on the connection
     */
    function query($sql, $connection);
    
    /**
     * Get a result set iterator for the result reference
     * generated by query()
     */
    function resultSetObject($resultResource, $className = null);
    
    /**
     * Get the number of rows affected by the last query
     */
    function getAffectedRows($connection);
    
    function getInsertedId($connection);
    
    /**
     * Get a result set iterator containing an array for the result reference
     */
    function resultSetArray($resultResource);
    
    function countRows($resultResource);
    
    function countColumns($resultResource);
}

?>
